function trim(val)
{
	 return val.replace(/(^\s*)|(\s*$)/g, "");  
}
 
function isMaxLen(o)
{  
	 var nMaxLen=o.getAttribute? parseInt(o.getAttribute("maxlength")):"";  
	 if(o.getAttribute && o.value.length>nMaxLen)
	 {      
	 	  o.value=o.value.substring(0,nMaxLen);  
	 }  
}
 
 
  
function selectAll(){
	var checkall = document.getElementById('checkall');
	var listsize = document.getElementById('listsize').value;
	for(var i=0;i<listsize;i++){
		if(checkall.checked){
			document.getElementById('checkone'+i).checked = true;
		}else{
			document.getElementById('checkone'+i).checked = false;
		}
	}
}

function judgeCheck()
{
    var pkid_string = '';
		var listsize = document.getElementById('listsize').value;
		for(var i=0;i<listsize;i++)
		{
				if(document.getElementById('checkone'+i).checked)
				{
					pkid_string += document.getElementById('checkone'+i).value+'|';
				}
		}
    return pkid_string;
}

function changeTime(val){

	var obj = document.getElementById(val+'_operating').value;
	if( obj == '' || obj.indexOf('-')>-1 || obj=='c' || obj=='d'){
		document.getElementById(val+'_g').style.display = 'none';
	}else{
		document.getElementById(val+'_g').style.display = 'inline';
	}
}

function updatestate(val){
	var oper = document.getElementById(val+'_operating').value;
	var listsize = document.getElementById('listsize').value;
	var ifcomment='';
	var pkid_string = '';
	for(var i=0;i<listsize;i++){
		if(document.getElementById('checkone'+i).checked){
			pkid_string += document.getElementById('checkone'+i).value+'|';
		}
	}
	document.getElementById('pkid').value = pkid_string;
	if(pkid_string == ''){
		alert('请选择要操作的信息!');
		return false;
	}
	if(oper =='')
	{
	  alert('请选择操作方式!');
	  return false;
	}
	else if(oper == '-')
	{
	   document.getElementById('pkid').value = pkid_string;
	   document.indexForm.action='/doTradeReg.do';
	   if(window.confirm('确认删除?'))
	   {
		  document.indexForm.submit();
	   }
	}
	else if(oper=='c' || oper=='d')
	{
	   
	   document.getElementById('pkid').value = pkid_string;
	   document.getElementById('state_code').value = oper;
	   document.getElementById('bpm_id').value = '4758';
	   document.indexForm.action='/doTradeReg.do';
	   if(window.confirm('确认提交吗?'))
	   {
		  document.indexForm.submit();
	   }
	}
	else
	{
	    document.getElementById('pkid').value = pkid_string;
		document.getElementById('up_operating').value = oper;
		document.getElementById('s_start_date').value = document.getElementById(val+'_start_date').value;
		document.getElementById('s_end_date').value = document.getElementById(val+'_end_date').value;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '2491';
		if(window.confirm('确认提交吗?'))
		{
			document.indexForm.submit();
		}
	
	 }
}

function deleteOneInfo(pkid,bpm_id)
{
	if(window.confirm('确认删除吗？'))
	{
	  window.location.href='/doTradeReg.do?pkid='+pkid+'&bpm_id='+bpm_id;
 	}
}


function subForm(){
	
  if(trim(document.getElementById('title').value)=="")
  {
       alert('请输入软件名称！');
       return; 
  }
  if(trim(document.getElementById('cat_attr').value)=='')
  {
      alert('请输入软件类别！');
      return; 
  }
  if(trim(document.getElementById('size').value)=='')
  {
      alert('请输入软件大小！');
      return; 
  }
  if(trim(document.getElementById('platform').value)=='')
  {
      alert('请输入应用平台！');
      return; 
  } 
  if(trim(document.getElementById('update_date').value)=='')
  {
      alert('请输入更新时间！');
      return; 
  }
  
  if(trim(document.getElementById('download_num').value)=='')
  {
      alert('请输入下载次数！');
      return; 
  }
  if(trim(document.getElementById('contact').value)=='')
  {
      alert('请输入联系人！');
      return; 
  }
  
  var dev_link = trim(document.getElementById('dev_link').value);
  if(dev_link!='')
  {
        var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
			+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" 
			+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" 
			+ "|" 
			+ "([0-9a-z_!~*'()-]+\.)*" 
			+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." 
			+ "[a-z]{2,6})" 
			+ "(:[0-9]{1,4})?" 
			+ "((/?)|" 
			+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
		var re = new RegExp(strRegex);
		if (!re.test(dev_link))
		{
		   alert("开发商链接的格式不正确!");
		   return;
		}
  }

  document.addForm.submit();    

}

function ChangeClassStyle()
{
	document.getElementById("flag_code").value = "1";
	document.getElementById("classId1").style.display="none";
	document.getElementById("classId2").style.display="block";
}

 
function showLinkSoft(){
   var cat_id = document.getElementById('g_cat_id').value; 
   var info = document.getElementById('g_keyword').value;
   info = encodeURI(encodeURI(info)); 
   if(cat_id=='' && info=='')
   {
      alert("至少选择或输入一种查询条件！");
      return;   
   }   
   
   var data = Math.round(Math.random()* 10000);   
   var bURL = "&cat_id="+cat_id+"&info="+info+"&data="+data;
   var gURL = "/program/admin/download/showMoreSoft.jsp?height=400&width=600"+bURL;  
   
   TB_show('相关软件',gURL,false);                                                       

}




function audit(val){
	if(val == 1){
		document.getElementById('state_code').value = 'c';
	}
	if(val == 2){
		document.getElementById('state_code').value = 'b';
		alert(document.getElementById('state_code').value);
	}
	document.addForm.submit();
}

function subUPdateForm()
{
  if(trim(document.getElementById('title').value)=="")
  {
       alert('请输入软件名称！');
       return; 
  }
  if(document.getElementById('flag_code').value == "1")
  {
	   if(document.getElementById("s_cat_attr").value=="")
	   {
		  alert("请选择所属分类！");
		  document.getElementById('s_cat_attr').focus();
		  return false;
	   }
	   document.getElementById("cat_attr").value = document.getElementById("s_cat_attr").value;
	   
   }
  if(trim(document.getElementById('size').value)=='')
  {
      alert('请输入软件大小！');
      return; 
  }
  if(trim(document.getElementById('platform').value)=='')
  {
      alert('请输入应用平台！');
      return; 
  } 
  if(trim(document.getElementById('update_date').value)=='')
  {
      alert('请输入更新时间！');
      return; 
  }
  
  if(trim(document.getElementById('download_num').value)=='')
  {
      alert('请输入下载次数！');
      return; 
  }
  if(trim(document.getElementById('contact').value)=='')
  {
      alert('请输入联系人！');
      return; 
  }
  
  var dev_link = trim(document.getElementById('dev_link').value);
  if(dev_link!='')
  {
        var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
			+ "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" 
			+ "(([0-9]{1,3}\.){3}[0-9]{1,3}" 
			+ "|" 
			+ "([0-9a-z_!~*'()-]+\.)*" 
			+ "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." 
			+ "[a-z]{2,6})" 
			+ "(:[0-9]{1,4})?" 
			+ "((/?)|" 
			+ "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
		var re = new RegExp(strRegex);
		if (!re.test(dev_link))
		{
		   alert("开发商链接的格式不正确!");
		   return;
		}
  }

  document.addForm.submit();  

}






